1 - 1
1
输出
"你好请登录"
print("你好，请登录")

2
计算购物金额
num = int(input())
price = int(input())
sum = num * price
print('数量：', num, sep='')
print('单价：', price, sep='')
print('金额：', sum, sep='')

2 - 1
1
计算输出购买商品的实付总额与平均价格等
n1 = 6  # 商品1数量
p1 = 4.5  # 商品1单价
n2 = 1  # 商品2数量
p2 = 26.5  # 商品2单价
d = 0.2  # 折扣率
c = n1 * p1 + n2 * p2
dc = d * c
pay = c - dc
av = pay / (n1 + n2)
print('商品总额：￥', round(c, 2))
print('商品优惠：-￥', round(dc, 2))
print('实付总额：￥', round(pay, 2))
print('实付平均价格：￥', round(av, 2))

2 - 2
1
输出2022年3月的月历
import calendar

cal = calendar.month(2022, 3)
print(cal)

2
输出当前时间
import time

localtime = time.asctime(time.localtime(time.time()))
print("本地时间为:", localtime)

3 - 2
1
判断成绩等级
score = eval(input())
grade = ""
if score >= 90:
    grade = "优秀"
elif score >= 80:
    grade = "良好"
elif score >= 70:
    grade = "中等"
elif score >= 60:
    grade = "及格"
else:
    grade = "不及格"
print("{}分：{}".format(score, grade))

2
网上购书费用结算
计算优惠
if t >= 299:
    yh = 15
elif t >= 148:
    yh = 15
else:
    yh = 0
# 计算返现金额
if t >= 100:
    fx = 50
else:
    fx = 0
# 计算运费
if t >= 49:
    yf = 0
else:
    yf = 6
# 计算优惠总额
yhze = fx + yh
# 计算实付金额
sf = t - yh - fx
print("应付总商品金额：{}元".format(t))
print("返现金额：{}元".format(fx))
print("优惠金额：{}元".format(yh))
print("优惠总额：{}元".format(yhze))
print("实付金额：{}元".format(sf））

3 - 3
1
100
以内的自然数之和
n = 1
sum = 0
while n <= 100:
    sum = sum + n
    n += 10
print("1+2+……+100=5050")

2
52
周存钱发
money = range(10, 530, 10)
save = 0
for n in money:
    save = save + n
print("一年共存款：{}元".format(save))

3
水仙花数
for i in range(100, 1000):
    x = i // 100
    y = i // 10 % 10
    z = i % 10
    if x ** 3 + y ** 3 + z ** 3 == i:
        print(f"{i}")

3 - 4
1
输出100以内的素数
for n in range(2, 100):
    for m in range(2, n):
        if n % m == 0:
            break
    else:
        print(n, end=' ')

2
九九乘法表
for j in range(1, 10):
    for i in range(1, j + 1):
        print('{}*{}={:<3}'.format(j, i, i * j), end='')
    print()

3
输出如下图形
layer = int(input(""))
for i in range(1, layer + 1):
    num1 = layer - i
    for j in range(num1):
        print(" ", end="")

    num2 = i * 2 - 1
    for j in range(num2):
        print("*", end="")
    print("")

4 - 1
1
统计并输出字符串中每个字符出现的次数
Str = (
    'I have a dream that one day every valley shall be exalted, and every hill and mountain shall be made low, the rough places will be made plain, and the crooked places will be made straight, and the glory of the Lord shall be revealed and all flesh shall see it together.')
resoult = {}
for i in Str:
    resoult[i] = Str.count(i)
for key in resoult:
    print(f'{key}的个数是：{resoult[key]}')

2
集五福卡
lst = ['爱国福', '富强福', '和谐福', '友善福', '敬业福']
dct = dict.fromkeys(lst)
lst1 = ['爱国福', '富强福', '友善福', '敬业福', '爱国福', '爱国福', '友善福', '敬业福']
for item in dct:
    dct[item] = lst1.count(item)
    print(item, '共集了:', dct[item], '个')

4 - 2
1
输出N以内所有的素数


def is_prime(n):
    """判断素数的函数,接收一个正整数为参数，参数是素数时返回True，否则返回False。减小判定区间，减少循环次数，提升效率"""
    if n < 2:
        return False
    i = 2
    while (i < n):
        if (n % i) == 0:
            return False
        i += 1
    else:
        return True


def output_prime(number):
    """接收一个正整数为参数，遍历从0到number之间的所有整数
    在一行中输出不大于number的所有素数，每个数字后一个空格，函数无返回值。"""
    for j in range(2, number + 1):
        if is_prime(j):
            print(j, end=' ')


positive_int = int(input())
output_prime(positive_int)

2
统计字符个数


def count_test(st):
    cap, small, num, other = 0, 0, 0, 0
    for i in st:
        if i.isupper():
            cap = cap + 1
        elif i.islower():
            small = small + 1
        elif i.isdigit():
            num = num + 1
        else:
            other = other + 1
    print('大写字母： %d\n小写字母： %d\n数字： %d\n其它字符： %d\n' % (cap, small, num, other))


string = input()
count_test(string)